﻿// -----------------------------------------------------------------------
// <copyright file="Screen.cs" company="Diddly Squad">

// </copyright>
// -----------------------------------------------------------------------

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace DiddlySquat
{

	/// <summary>
	/// Class to represent base class for all screens
	/// </summary>
	public abstract class Screen
	{
		protected KeyboardState state, oldState;

		//The event associated with the Screen. This event is used to raise events
		//back in the main game class to notify the game that something has changed
		//or needs to be changed
		protected EventHandler ScreenEvent;

		/// <summary>
		/// Basic constructor for the <see cref="Screen"/> class.
		/// </summary>
		/// <param name="theScreenEvent">The screen event.</param>
		public Screen(EventHandler theScreenEvent)
		{
			ScreenEvent = theScreenEvent;
		}

		/// <summary>
		/// Updates any information specific to the screen
		/// </summary>
		/// <param name="theTime">The time.</param>
		public virtual void Update(GameTime theTime)
		{
		}

		/// <summary>
		/// Draws any objects specific to the screen
		/// </summary>
		/// <param name="theBatch">The batch.</param>
		public virtual void Draw(SpriteBatch theBatch)
		{
		}

		/// <summary>
		/// Checks the key for up & down positions (pressed on current update round).
		/// </summary>
		/// <param name="theKey">The key.</param>
		/// <returns>True, if key was pressed</returns>
		protected bool CheckKey(Keys theKey)
		{
			return state.IsKeyUp(theKey) && oldState.IsKeyDown(theKey);
		}
	}
}
